home *** CD-ROM | disk | FTP | other *** search
/ 17 Bit Software 6: Level 6 / 17 Bit - Level 6 (1998)(Epic Marketing)[!].iso / quartz / q1082.dms / q1082.adf / src.lzh / Fig / remove.c < prev    next >
C/C++ Source or Header  |  1991-07-18  |  4KB  |  142 lines

  1. /* 
  2.  *    FIG : Facility for Interactive Generation of figures
  3.  *
  4.  *    Copyright (c) 1985 by Supoj Sutanthavibul (supoj@sally.UTEXAS.EDU)
  5.  *    January 1985.
  6.  *    1st revision : Aug 1985.
  7.  *
  8.  *    %W%    %G%
  9. */
  10. #include "fig.h"
  11. #include "resources.h"
  12. #include "func.h"
  13. #include "object.h"
  14. #include "paintop.h"
  15.  
  16. #define            TOLERANCE    7
  17.  
  18. extern            (*canvas_kbd_proc)();
  19. extern            (*canvas_locmove_proc)();
  20. extern            (*canvas_leftbut_proc)();
  21. extern            (*canvas_middlebut_proc)();
  22. extern            (*canvas_rightbut_proc)();
  23. extern            null_proc();
  24. extern            set_popupmenu();
  25.  
  26.  
  27. extern int        foreground_color, background_color;
  28.  
  29.             init_remove();
  30.  
  31. remove_selected()
  32. {
  33.     canvas_kbd_proc = null_proc;
  34.     canvas_locmove_proc = null_proc;
  35.     canvas_leftbut_proc = init_remove;
  36.     canvas_middlebut_proc = null_proc;
  37.     canvas_rightbut_proc = set_popupmenu;
  38.     set_cursor(&buster_cursor);
  39.     }
  40.  
  41. init_remove(x, y)
  42. int    x, y;
  43. {
  44.     extern F_line        *line_search();
  45.     extern F_arc        *arc_search();
  46.     extern F_ellipse    *ellipse_search();
  47.     extern F_text        *text_search();
  48.     extern F_spline        *spline_search();
  49.     extern F_compound    *compound_search();
  50.     extern F_compound    objects;
  51.     F_line        *l;
  52.     F_arc        *a;
  53.     F_ellipse    *e;
  54.     F_text        *t;
  55.     F_spline    *s;
  56.     F_compound    *c;
  57.     int        dummy;
  58.  
  59.     if ((c = compound_search(x, y, TOLERANCE, &dummy, &dummy)) != NULL) {
  60.         draw_compoundbox(c, INV_PAINT);
  61.         erase_compound(c);
  62.         delete_compound(&objects.compounds, c);
  63.         clean_up();
  64.         set_action_object(F_REMOVE, O_COMPOUND);
  65.         set_latestcompound(c);
  66.         set_modifiedflag();
  67.         }
  68.     else if ((l = line_search(x, y, TOLERANCE, &dummy, &dummy)) != NULL) {
  69.         toggle_linepointmarker(l);
  70.         draw_line(l, ERASE);
  71.         delete_line(&objects.lines, l);
  72.         clean_up();
  73.         set_action_object(F_REMOVE, O_POLYLINE);
  74.         set_latestline(l);
  75.         set_modifiedflag();
  76.         }
  77.     else if ((t = text_search(x, y)) != NULL) {
  78.         draw_text(t, INV_PAINT);
  79.         delete_text(&objects.texts, t);
  80.         clean_up();
  81.         set_action_object(F_REMOVE, O_TEXT);
  82.         set_latesttext(t);
  83.         set_modifiedflag();
  84.         }
  85.     else if ((e = ellipse_search(x, y, TOLERANCE, &dummy, &dummy)) != NULL){
  86.         toggle_ellipsepointmarker(e);
  87.         pw_batch_on(canvas_pixwin);
  88.         draw_ellipse(e, background_color);
  89.         pw_batch_off(canvas_pixwin);
  90.         delete_ellipse(&objects.ellipses, e);
  91.         clean_up();
  92.         set_action_object(F_REMOVE, O_ELLIPSE);
  93.         set_latestellipse(e);
  94.         set_modifiedflag();
  95.         }
  96.     else if ((a = arc_search(x, y, TOLERANCE, &dummy, &dummy)) != NULL){
  97.         toggle_arcpointmarker(a);
  98.         pw_batch_on(canvas_pixwin);
  99.         draw_arc(a, background_color);
  100.         pw_batch_off(canvas_pixwin);
  101.         delete_arc(&objects.arcs, a);
  102.         clean_up();
  103.         set_action_object(F_REMOVE, O_ARC);
  104.         set_latestarc(a);
  105.         set_modifiedflag();
  106.         }
  107.     else if ((s = spline_search(x, y, TOLERANCE, &dummy, &dummy)) != NULL) {
  108.         toggle_splinepointmarker(s);
  109.         pw_batch_on(canvas_pixwin);
  110.         draw_spline(s, ERASE);
  111.         pw_batch_off(canvas_pixwin);
  112.         delete_spline(&objects.splines, s);
  113.         clean_up();
  114.         set_action_object(F_REMOVE, O_SPLINE);
  115.         set_latestspline(s);
  116.         set_modifiedflag();
  117.         }
  118.     remove_selected();
  119.     }
  120.  
  121. remove_all()
  122. {
  123.     extern F_compound    objects;
  124.     extern F_compound    saved_objects;
  125.     extern int        last_action;
  126.  
  127.     clean_up();
  128.     set_action_object(F_REMOVE, O_ALL_OBJECT);
  129.  
  130.     /* Aggregate assignment between variables is allowed,
  131.     but not from constant (weird!?) */
  132.  
  133.     saved_objects = objects;
  134.  
  135.     objects.arcs = NULL;
  136.     objects.compounds = NULL;
  137.     objects.ellipses = NULL;
  138.     objects.lines = NULL;
  139.     objects.splines = NULL;
  140.     objects.texts = NULL;
  141.     }
  142.